﻿using System;
using System.ComponentModel;
using System.Windows;
namespace WPFExcelReport
{
    /// <summary>
    /// 干燥
    /// </summary>
    public partial class K14MD
    {
        #region ==TM===========
        public static readonly DependencyProperty TMProperty = DependencyProperty.Register("TM",
            typeof(string), typeof(K14MD),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnTMChanged));
        public string TM
        {
            get
            {
                return (string)GetValue(TMProperty);
            }
            set
            {
                SetValue(TMProperty, value);
            }
        }
        private static void OnTMChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as K14MD;
            if (src != null)
            {
                src.TM = (string)e.NewValue;
            }
        }
        #endregion

        #region ==FS===========
        public static readonly DependencyProperty FSProperty = DependencyProperty.Register("FS",
            typeof(string), typeof(K14MD),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFSChanged));
        public string FS
        {
            get
            {
                return (string)GetValue(FSProperty);
            }
            set
            {
                SetValue(FSProperty, value);
            }
        }
        private static void OnFSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as K14MD;
            if (src != null)
            {
                src.FS = (string)e.NewValue;
            }
        }
        #endregion


        #region ==IsShowMT===========
        public static readonly DependencyProperty IsShowMTProperty = DependencyProperty.Register("IsShowMT",
            typeof(bool), typeof(K14MD),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowMTChanged));
        public bool IsShowMT
        {
            get
            {
                return (bool)GetValue(IsShowMTProperty);
            }
            set
            {
                SetValue(IsShowMTProperty, value);
            }
        }
        private static void OnIsShowMTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as K14MD;
            if (src != null)
            {
                src.IsShowMT = (bool)e.NewValue;
            }
        }
        #endregion

        public K14MD()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VSDDAT();
            DataContext = MV;
            SDSA = "14MD"; 
            InitializeComponent(); 
        }
        public override void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            base.Window_Loaded(sender, e); 
            Load();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {
                FS = "";
                IsShowMT = false;
            }
            else
            {
                if (dwMaster["KEY"].ToString() == "GH")
                {
                    FS = "GH";
                    IsShowMT = true;
                }
            }
        }
        public void Load()
        {
            if (SDSA.Trim().Length == 0)
                return;
            dwData = TBMain.NewRow();
            dwData["SDSA"] = "0014";
             dwData["SDKEY"] = " AND SDKEY ='XXXXXX'";
            SResult = ((VSDDAT)MV).QuerySDDAT(dwData, 14);
            MergeData(SResult, false);
            dwData = TBMain.Rows.Add();
            dwData["SDSA"] = "14MD";
            dwData["KEY"] = "XG";
            dwData["DES"] = "悬挂晾干";   
            dwData = TBMain.Rows.Add();
            dwData["SDSA"] = "14MD";
            dwData["KEY"] = "PT";;
            dwData["DES"] = "平摊晾干"; 
            dwData = TBMain.Rows.Add();
            dwData["SDSA"] = "14MD";
            dwData["KEY"] = "PH";
            dwData["DES"] = "平摊烘干"; 
            dwData = TBMain.Rows.Add();
            dwData["SDSA"] = "14MD";
            dwData["KEY"] = "GH";
            dwData["DES"] = "滚筒烘干";             
        } 
    }
}
